$(document).ready(function() {
	
	/**
	 * Tabela
	 */
	var oTable = $('#comanda').dataTable({
		"bDeferRender": true,
    	"aoColumns": [
			{ "mData": "tb_usuario_login_usuario", "sClass": "center" },
			{ "mData": "total", "sClass": "center" , "mRender" : 
				function (total) {
					if (total == null) {
						return 'Sem pedidos';
					} else {
						return 'R$ ' + total;
					}
				} },
			{ "mData": "time_inicio_comanda", "sClass": "center" },
			{ "mData": "status_comanda", "sClass": "center" },
			{ "mData": "id_comanda", "mRender": function ( id, type, full ) { return '<a href="comandas/fechar/'+id+'" onclick="return confirma()"><i class="icon-trash"></i>Acao</a>' }, "sClass": "center" }
		],
     	"aaSorting": [[ 3, "desc" ]],
    	"sPaginationType": "full_numbers",
    	"iDisplayLength": 100
	});
	
	/**
	 * Estutando Bar
	 */
	oTable.fnReloadAjax('comandas/ler');
		(function escutaDados() {
			setTimeout(function() {
			oTable.fnReloadAjax('comandas/ler'); 
			escutaDados();
		}, 2000);
	})();
	
	$(".fancybox").fancybox({
	});
});